var id = T.p("id");
var belongType = T.p("belongType");
var belongId = T.p("belongId");
if(!belongType){
    belongType =  1;
}

var paramTypes= T.getDictItems("param_type");
var dbKeys = T.getDictDynas("db_key");
var vm = new Vue({
	el:'#rrapp',
	data:{
		title:"新增",
		workParams:{
            type:paramTypes[0].dictCode,
            dbKey:dbKeys[0].dictCode
		},
        paramTypes:paramTypes,
        dbKeys:dbKeys
	},
	created: function() {
		if(id != null){
			this.title = "修改";
			this.getInfo(id)
		}
    },
	methods: {
		getInfo: function(id){
			$.get("../workParams/info/"+id, function(r){
                vm.workParams = r.workParams;
            });
		},
		saveOrUpdate: function (event) {
			var url = vm.workParams.id == null ? "../workParams/save" : "../workParams/update";
            vm.workParams.belongType=belongType;
            vm.workParams.belongId = belongId;
			$.ajax({
				type: "POST",
			    url: url,
			    data: JSON.stringify(vm.workParams),
			    success: function(r){
			    	if(r.code === 0){
						alert('操作成功', function(index){
							vm.back();
						});
					}else{
						alert(r.msg);
					}
				}
			});
		},
		back: function (event) {
			history.back();
		}
	}
});
